var co = require('co');
var seqModule = require('../../models/index');
var db = new seqModule();
var util = require('../../common/util');
var meetSubjectController = {
    getSubjectById: function (req, res) {
        co(function () {
            var params = {};
            var paramT = {};
            var paramU = {};
            if(req.query.openId != undefined){
                paramU.openId = req.query.openId;
            }
			console.log(req.query.openId+"===========================");
            var include = [{model:db.buildModule,attributes:['buildTitle']},{model:db.meetScheduleModule,include:[{model:db.speakHostModule},{model:db.meetOrderModule,where:paramU,required:false}]}];
            paramT.include = include;
            if (req.params.id != undefined) {
                params["id"] = req.params.id;
            }
            paramT["where"] = params;
            paramT["order"] = [[ db.meetScheduleModule, 'startTime','ASC' ] ];
            db.meetSubjectModule.findOne(paramT).then(function (result) {
                res.status(200).json(result);
            });
        }).catch(function (e) {
            res.status(500).json({"message":"服务异常！"});
            console.log(e);
        })
    }
}
module.exports = meetSubjectController;